<?php 
    echo $this->Html->script(array(
        'app/clientes/lib_clientesEdicion'
    ), array('inline'=>false));

	$idCliente = "";
	$ruc = "";
	$razonSocial = "";
	$apellidoPaterno = "";
	$apellidoMaterno = "";
	$nombres = "";
	$dni = "";
	$telefono = "";
	$correo = "";
	
	if(isset($objCliente)){
		if(count($objCliente)>0){
			$idCliente = $objCliente["Cliente"]["idCliente"];
			$ruc = $objCliente["Cliente"]["ruc"];
			$razonSocial = $objCliente["Cliente"]["razonSocial"];
			$idTipoPersonaItem = $objCliente["TipoPersona"]["idItem"];
			$apellidoPaterno = $objCliente["Cliente"]["apellidoPaterno"];
			$apellidoMaterno = $objCliente["Cliente"]["apellidoMaterno"];
			$nombres = $objCliente["Cliente"]["nombres"];
			$dni = $objCliente["Cliente"]["dni"];
			$telefono = $objCliente["Cliente"]["telefono"];
			$correo = $objCliente["Cliente"]["correo"];
		}
	}	
?>
<script type="text/javascript">
$(window).load(function(){
	fnCambiarCamposFormulario();
});
</script>
<?php if(isset($msjRegistroCliente)) {?>
<script type="text/javascript">
jAlert('<?php echo $msjRegistroCliente; ?>',TITULO_MENSAJE);
</script>
<?php }?>
<div class="subtitulo">
	<div class="divBannerCabecera" align="left">
		<table border="0" cellpadding="1">
			<tr>
			<td><img src="<?php echo Router::url('/img/iconos/icono_clientes.png',false); ?>" width="45" height="45" border="0" alt="" title="" /></td>
			<td width="3%"></td>
			<td>Nuevo Cliente</td>
			</tr>
		</table>
	</div>
</div>
<br />
<div class="cuerpoPagina">
<fieldset class="fieldsetForm">
	<legend class="ui-widget-header">Datos de Cliente</legend>
	<div align="center">
	
	<form id="formRegistro" name="formRegistro" action="<?php echo Router::url("/Clientes/guardar_cliente"); ?>" method="post">
		<input type="hidden" id="idCliente" name="data[Cliente][idCliente]" value="<?php echo $idCliente; ?>" />
		<table border="0">
			<tr>
				<td align="right">Tipo Persona : </td>
				<td align="left">
					<?php $nombreCampo = "data[Cliente][idTipoPersonaItem]"; ?>
					<?php if($idCliente != ""){?>
					<input type="hidden" id="idTipoPersonaItem" name="<?php echo $nombreCampo; ?>" value="<?php echo $idTipoPersonaItem; ?>"  />
					<?php }?>
					
					<select name="<?php if($idCliente==""){echo $nombreCampo;} ?>" <?php if($idCliente == "") { echo "id='idTipoPersonaItem'"; } ?>
							onchange="fnCambiarCamposFormulario();" 
							<?php if($idCliente != "") { echo "disabled='disabled'"; }?>>
						<?php 
						$dimTiposPersonas = count($tiposPersonas);
						$selected = "";
						for($i = 0;$i<$dimTiposPersonas;$i++){ 
							$objTipo = $tiposPersonas[$i]["CatalogoDetalle"];
							
							if($objTipo["idItem"] == $idTipoPersonaItem){
								$selected="selected='selected'";
							}else{
								$selected="";
							}
						?>
						<option value="<?php echo $objTipo["idItem"];?>" <?php echo $selected; ?>><?php echo $objTipo["descripcion"]; ?></option>
						<?php } ?>
					</select>
				</td>
				<td colspan="8"></td>
			</tr>
			<tr>
				<td align="right">Ruc : </td>
				<td align="left"><input type="text" id="ruc" name="data[Cliente][ruc]" value="<?php echo $ruc; ?>" maxlength="30" disabled="disabled" /></td>
				<td align="center" width="2%"></td>
				<td align="right">Raz&oacute;n Social : </td>
				<td align="left" colspan="4"><input type="text" id="razonSocial" name="data[Cliente][razonSocial]"  maxlength="200" value="<?php echo $razonSocial; ?>" style="width:100%;" disabled="disabled" /></td>
			</tr>
			<tr>
				<td align="right">Ap. Paterno : </td>
				<td align="left"><input type="text" id="apellidoPaterno" maxlength="50" name="data[Cliente][apellidoPaterno]" value="<?php echo $apellidoPaterno; ?>" disabled="disabled"/></td>
				<td align="center" width="2%"></td>
				<td align="right">Ap. Materno : </td>
				<td align="left"><input type="text" id="apellidoMaterno" maxlength="50" name="data[Cliente][apellidoMaterno]" value="<?php echo $apellidoMaterno; ?>" disabled="disabled" /></td>
				<td align="center" width="2%"></td>
				<td align="right">Nombres :</td>
				<td align="left"><input type="text" id="nombres" maxlength="50" name="data[Cliente][nombres]" value="<?php echo $nombres; ?>" style="width:100%;" disabled="disabled" /></td>
			</tr>
			<tr>
				<td align="right">DNI : </td>
				<td align="left"><input type="text" id="dni" maxlength="10" name="data[Cliente][dni]" value="<?php echo $dni; ?>" disabled="disabled" /></td>
				<td align="center" width="2%"></td>
				<td align="right"></td>
				<td align="left"></td>
				<td align="center" width="2%"></td>
				<td align="right"></td>
				<td align="left"></td>
			</tr>
			<tr>
				<td align="right">Tel&eacute;fono : </td>
				<td align="left"><input type="text" id="telefono" name="data[Cliente][telefono]" maxlength="20" value="<?php echo $telefono; ?>" /></td>
				<td align="center" width="2%"></td>
				<td align="right">Correo : </td>
				<td align="left" colspan="4"><input type="text" id="correo" name="data[Cliente][correo]"  maxlength="40" value="<?php echo $correo; ?>" style="width:100%;" /></td>
			</tr>
		</table>
	</form>
	</div>
	<br />
	<div align="center">
		<input id="btnGuardar" type="button" value="Guardar"
			onclick="fnGuardarCliente();" class="btn btnposicion"
   			style="background-image: url(<?php echo Router::url('/img/iconos/guardar.png',false); ?>)" />
   			
   		<input id="btnConsultarClientes" type="button" value="Consultar Clientes"
			onclick="fnConsultarClientes();" class="btn btnposicion"
   			style="background-image: url(<?php echo Router::url('/img/iconos/buscar.png',false); ?>)" />
   			
   		<input id="btnNuevaOrden" type="button" value="Crear Orden de Trabajo"
			onclick="fnCrearOrdenTrabajo();" class="btn btnposicion"
   			style="background-image: url(<?php echo Router::url('/img/iconos/report.png',false); ?>)" />
	</div>
</fieldset>
</div>